package com.acane.instagram.utils;

import com.cloudinary.Cloudinary;
import com.cloudinary.utils.ObjectUtils;

import java.io.InputStream;
import java.util.Map;

public class HeicConverter {

    private static final Cloudinary cloudinary = new Cloudinary(ObjectUtils.asMap(
            "cloud_name", "dmdh7adxq",
            "api_key", "841438538299693",
            "api_secret", "aGKOITj6vvDlicQHf12UPKkNyiw"
    ));

    public static String convertHeicToJpg(InputStream heicStream) throws Exception {
        Map uploadResult = cloudinary.uploader().upload(heicStream, ObjectUtils.asMap(
                "resource_type", "image",
                "format", "jpg"
        ));
        return (String) uploadResult.get("secure_url");
    }
}
